package com.tanhua.server.Cache;

import com.tanhua.domain.mongo.Conclusion;
import com.tanhua.domain.mongo.Question;
import com.tanhua.domain.mongo.Questionnaire;
import com.tanhua.dubbo.api.mongo.SoulApi;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SoulCache {

    @Reference
    private SoulApi soulApi;

    //使用缓存获取文件列表
    @Cacheable(value="Soultest")
    public List<Questionnaire> findSoultest(){
        return soulApi.findSoultest();
    }

    //使用缓存技术的问题列表
    @Cacheable(value="Question",key ="#questionsId.get(0)+'_'+#questionsId.size()")
    public List<Question> findQuestionsByIdList(List<Integer> questionsId){
        return soulApi.findQuestionsByIdList(questionsId);
    }

    //使用缓存技术的结论
    @Cacheable(value="Concluson",key ="#cid")
    public Conclusion findConclusionsById(Integer cid){
        return soulApi.findConclusionsById(cid);
    }
}
